package com.wzw.springboot.principle.use.security.constant;

import com.wzw.springboot.principle.use.security.enums.AuthenticationEnum;

import java.util.Locale;

/**
 * @author Wangzhiwen
 */
public interface Redis {

    String semicolon = ":";

    String LOGIN_WAY = "login_way" + semicolon;

    String LOGIN_ERROR = "login_error" + semicolon;

    String LOGIN_USER_TOKENS = "login_user_tokens" + semicolon;

    static String generateTokenKey(Long id, String uid) {
        return LOGIN_USER_TOKENS + id + semicolon + uid;
    }

    static String generateCredentialsKey(AuthenticationEnum authenticationEnum, String principal) {
        return LOGIN_WAY + authenticationEnum.name().toLowerCase(Locale.ROOT) + semicolon + principal;
    }
}
